home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1798 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.5 KB  |  78 lines

  1. Path: rose_ip171.efn.org!peterf
  2. From: peterf@gears.efn.org (Peter F.)
  3. Newsgroups: comp.lang.c++
  4. Subject: BGI Driver.  Reply
  5. Date: Fri, 12 Jan 1996 16:51:38
  6. Organization: Southern Oregon Unified Networking District (SOUND)
  7. Message-ID: <peterf.74.0010DCCD@gears.efn.org>
  8. NNTP-Posting-Host: rose_ip171.efn.org
  9. X-Newsreader: Trumpet for Windows [Version 1.0 Rev A]
  10.  
  11. Dear Wong,
  12.  
  13. Here is some code I wrote myself, in order to use the .bgi driver.  Remember 
  14. the driver must be in your compilers bgi directory.  (ex.  C:\borlandc\bgi )
  15.  
  16. Your Friend,
  17.  
  18. Peter Felten
  19. peterf@gears.efn.org
  20.  
  21. #include <iostream.h>
  22. #include <graphics.h>
  23. #include <conio.h>
  24. #include <stdio.h>
  25. #include <process.h>
  26.  
  27. int huge DetectVGA256(void);
  28. void checkgerrors(void);
  29.  
  30. int main(void)
  31.  {
  32.  int i, gdriver, gmode, y, wthx, hthy;
  33.  gdriver=installuserdriver("VGA256" , DetectVGA256);
  34.  gdriver=DETECT;
  35.  checkgerrors();
  36.  initgraph(&gdriver,&gmode,"\\borlandc\\bgi");
  37.  checkgerrors();
  38.  
  39.  for (i=1; i<64; i++)
  40.   /* Mixing colors rd. gr. bl. to make different shades of color */
  41.   setrgbpalette(i, 60, i, 12);
  42.  
  43.    hthy = getmaxy() / 40;
  44.    wthx = getmaxx();
  45.    y = 0;
  46.    for (i=0; i<64; i++)
  47.    {
  48.       setfillstyle(SOLID_FILL, i);
  49.       bar(0, y, wthx, y+hthy);
  50.       y += hthy;
  51.    }
  52.  
  53.   getch();
  54.   closegraph();
  55.   return 0;
  56.  }
  57.  
  58. int huge DetectVGA256(void)
  59.  {
  60.  return 0;
  61.  }
  62.  
  63. void checkgerrors(void)
  64.  {
  65.    int gerror;
  66.    gerror = graphresult();
  67.    if (gerror != grOk)
  68.     {
  69.       cerr << "Graphics error: " << grapherrormsg(gerror) << endl;
  70.       cerr << "Press any key to halt: ";
  71.       getch();
  72.       exit(1);
  73.     }
  74.  }
  75.  
  76.  
  77.  
  78.